package com.chen.admin.service;


import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chen.admin.common.Result;
import com.chen.admin.entity.CheckIn;
import com.chen.admin.entity.CheckInGuestInfo;
import com.chen.admin.entity.Guest;
import com.chen.admin.mapper.CheckGuestMapper;
import com.chen.admin.mapper.CheckInGuestInfoMapper;
import com.chen.admin.mapper.CheckInMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class CheckInService {


    @Autowired
    private CheckInMapper checkInMapper;

    @Autowired
    private CheckGuestMapper checkGuestMapper;
    @Autowired
    private CheckInGuestInfoMapper checkInGuestInfoMapper;


    @Transactional(rollbackFor = Exception.class)
    public Result checkInGuest(CheckInGuestInfo guest) {
       int count= checkInGuestInfoMapper.checkInGuestInfo(guest);
       if(count==0){
           return Result.error("400","入住失败");
       }
       return Result.success("入住成功");



    }

    public List<CheckInGuestInfo> getCheckInGuestList() {
        List<CheckInGuestInfo> checkInGuestInfos = checkInGuestInfoMapper.selectList(new LambdaQueryWrapper<>());

        return checkInGuestInfos;
    }
}
